-- =====================================================================
-- 
--   File:      6.sql
--   Summary:   This script, run on the mirror server instance, creates a mirroring endpoint.  
--              You can discover your machine name and domain name (full computer name) by looking at the 
--              properties of your computer (on Windows XP, right-click My Computer, select Properties, and 
--              look on the Computer Name tab).
--  
--   Date:      May 8, 2006
-- 
-- ---------------------------------------------------------------------
-- 
--   This file is part of the Microsoft SQL Server Code Samples.
--   Copyright (C) Microsoft Corporation.  All rights reserved.
-- 
-- This source code is intended only as a supplement to Microsoft
-- Development Tools and/or on-line documentation.  See these other
-- materials for detailed information regarding Microsoft code samples.
-- 
-- THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF 
-- ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
-- PARTICULAR PURPOSE.
-- 
-- ===================================================================== 

-- Step 6 (on MIRROR)
-- create mirroring endpoint
-- 
CREATE ENDPOINT Mirroring
STATE = STARTED
AS TCP(LISTENER_PORT = 7023)
FOR database_mirroring (ROLE = PARTNER);

-- also on mirror, set partner to PRINCIPAL server 
--(This must be done on mirror first.)
ALTER DATABASE HADB SET PARTNER='tcp://machine_name.domain:7022';